import { PageParams, PageResult } from "@/types/common"
import request from "@/utils/request"
import { SetmealResult, SetmealWithDishResult } from "../../types/setmeal"

/**
 * 套餐分页查询
 * @param params 
 * @returns 
 */
type SetmealPageParams = PageParams & {
  name?: string;
  categoryId?: number;
  status?: number;
};
export const getAdminSetmealPageAPI = (params: SetmealPageParams) => {
  return request<PageResult<SetmealResult[]>>({
    method: 'GET',
    url: '/admin/setmeal/page',
    params
  })
}
/**
 * 套餐起售、停售
 * @param params 
 * @returns 
 */
export const postAdminSetmealStatusAPI = (params: { status: number, id: number }) => {
  return request({
    method: 'POST',
    url: `/admin/setmeal/status/${params.status}`,
    params: { id: params.id }
  })
}
/**
 * 根据id查询套餐
 * @param id 
 * @returns 
 */
export const getAdminSetmealAPI = (id: number) => {
  return request<SetmealWithDishResult>({
    method: 'GET',
    url: `/admin/setmeal/${id}`,
  })
}